package dst1.interceptor;

import org.hibernate.EmptyInterceptor;

public class SQLInterceptor extends EmptyInterceptor {

	private static final long serialVersionUID = 3894614218727237142L;

	static int loads;

	public String onPrepareStatement(String sql) {
		if (sql.toLowerCase().startsWith("select")
				&& (sql.toLowerCase().contains("computer") || sql.toLowerCase().contains("execution")))
			loads++;

		return sql;
	}

	/*
	 * @Override public boolean onLoad(Object entity, Serializable id, Object[]
	 * state, String[] propertyNames, Type[] types) { if (entity instanceof
	 * Computer || entity instanceof Execution) { loads++; }
	 * 
	 * return false; }
	 */

	public static int getLoads() {
		return loads;
	}

	public static void resetLoads() {
		loads = 0;
	}
}
